// Copyright DustedPixels.com 2008. All rights reserved.

package com.dustedpixels.jasmin.chips;

/**
 * @author micapolos@gmail.com (Michal Pociecha-Los)
 */
public final class AdderBenchmark {
  public final static int CYCLES = 350000000;
  public final static int SIZE = 1;
  public final static int BLOCKS = CYCLES / SIZE;
  public static void main(String[] args) {
    int[] IN = new int[SIZE];
    int[] OUT = new int[SIZE];

    for (int i = 0; i < SIZE; i++) {
      IN[i] = i;
      OUT[i] = 0;
    }
    
    Adder adder = new AdderImpl();
    Adder.Pins pins = new Adder.Pins();
    System.out.println("Start");
    long time = System.currentTimeMillis(); 
    for (int i = 0; i < BLOCKS; i++) {
      for (int j = 0; j < SIZE; j++) {
        pins.IN = IN[j];
        adder.update(pins);
        OUT[j] = pins.OUT;
      }
    }
    time = System.currentTimeMillis() - time;
    System.out.println("Stop: " + time + "ms (" + OUT[SIZE - 1] + ")");
    
    for (int i = 0; i < SIZE; i++) {
      IN[i] = i;
      OUT[i] = 0;
    }

    FastAdder fastAdder = new FastAdderImpl();
    FastAdder.Pins fastPins = new FastAdder.Pins();
    fastPins.IN = IN;
    fastPins.OUT = OUT;
    System.out.println("Start");
    time = System.currentTimeMillis(); 
    for (int i = 0; i < BLOCKS; i++) {
      fastAdder.update(fastPins, SIZE);
    }
    time = System.currentTimeMillis() - time;
    System.out.println("Stop: " + time + "ms (" + OUT[SIZE - 1] + ")");
  }
}
